package com.school.chapter02.stack_;

import java.util.Stack;
@SuppressWarnings({"all"})
public class Conversion {
    public static void main(String[] args) {
        int i1 = 8;
        System.out.println(new Conversion().conversion(i1, 8));
    }

    private String conversion(int num, int n) {
        Stack<Integer> myStack = new Stack<Integer>();
        Integer result = num;
        while (true) {
// 
            myStack.push(result % n);
            result = result / n;
            if (result == 0) {
                break;
            }
        }
        StringBuilder sb = new StringBuilder();
// 
        while ((result = myStack.pop()) != null) {
            sb.append(result);
        }
        return sb.toString();
    }

}
